<?php
    include "header.html";
?>
<!--breadcrumb S-->
<div class="mid">
  <h2 class="f12">
    <b class="ico-bc"></b>公司名: <?php echo $company['name']; ?>
    <span class="ico-nav"></span>
  </h2>
</div>
<div id="container" class="container" onselectstart="return false;"> 
  <div class="wrapper mid" id="datawrap">
      <!--主体 S-->
      <div class="main"> 
        <!--grouplist S-->
          <div id="content" class="grid-view">
            <?php
                if ($groupid === NULL)
                {
            ?>
            <h1>所有群组</h1>
            <table width="710px" border="1" class="items">
              <tr>
                <th>群组名</th>
                <th>操作</th>
              </tr>
            <tbody id="filelistwrap">
            <?php
                    $odd = true;
                    foreach($groups as $row)
                    {
                        $odd = !$odd;
            ?>
              <tr class="<?php echo $odd?"odd":"even"; ?>">
                <td><a href="companyadmin.php?groupid=<?php echo $row['userid']; ?>"><?php echo $row['username']; ?></a></td>
                <td><a href="companyadmin.php?groupid=<?php echo $row['userid']; ?>">管理</a></td>
              </tr>
            <?php  } ?>
            </tbody>
            </table>
            <h2><a href="/register.php?type=group">创建新群</a></h2>
            <?php
                }else{
                    echo "<h1>当前群组:".$group["username"]."</h1>";
                }
            ?>
        </div>
        <!--grouplist E--> 
        <?php
            if ($groupid != NULL)
            {
        ?>
        <!--groupuserlist S-->
          <div id="content" class="grid-view">
            <h1>群组用户</h1>
            <table width="710px" border="1" class="items">
              <tr>
                <th>用户名</th>
                <th>类型</th>
                <th>权限</th>
                <th>操作</th>
              </tr>
            <tbody id="filelistwrap">
            <?php
                $odd = true;
                foreach($groupusers as $row)
                {
                    $odd = !$odd;
            ?>
              <tr class="<?php echo $odd?"odd":"even"; ?>">
                <td><?php echo $row['username']; ?></td>
                <td><?php if ($row['typeid'] == 1) echo "普通用户"; else echo "管理员"; ?> </td>
                <td><p class="font12"><label for="edit"><input name="right_<?php echo $row['userid']; ?>" id="edit" type="checkbox" checked="" value="0">上传</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="read"><input name="right_<?php echo $row['userid']; ?>" id="read" type="checkbox" value="1">删除</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="download"><input name="right_<?php echo $row['userid']; ?>" id="download" type="checkbox" value="2">分享</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="null"><input name="right_<?php echo $row['userid']; ?>" id="null" type="checkbox" value="3">引用</label></p></td>
                <td><a href="/companyadmin.php?cmd=remove&userid=<?php echo $row['userid']; ?>&groupid=<?php echo $groupid; ?>">移除</a></td>
              </tr>
            <?php
                }
            ?>
            </tbody>
            </table>
        </div>
        <!--groupuserlist E--> 
        <?php } ?>
        <!--userlist S-->
          <div id="content" class="grid-view">
            <h1>所有用户</h1>
            <table width="710px" border="1" class="items">
              <tr>
                <th>用户名</th>
                <th>类型</th>
                <?php
                    if ($groupid != NULL)
                    {
                ?>
                <th>操作</th>
                <?php } ?>
              </tr>
            <tbody id="filelistwrap">
            <?php
                $odd = true;
                foreach($users as $row)
                {
                    $odd = !$odd;
            ?>
              <tr class="<?php echo $odd?"odd":"even"; ?>">
                <td><?php echo $row['username']; ?></td>
                <td><?php if ($row['typeid'] == 1) echo "普通用户"; else echo "管理员"; ?> </td>
                <?php
                    if ($groupid != NULL)
                    {
                ?>
                <td><a href="/companyadmin.php?cmd=add&userid=<?php echo $row['userid']; ?>&groupid=<?php echo $groupid; ?>">加入</a></td>
                <?php } ?>
              </tr>
            <?php
                }
            ?>
            </tbody>
            </table>
            <h2><a href="/register.php">创建新用户</a></h2>
        </div>
        <!--userlist E--> 
      </div>
<div class="cl"></div>
  </div>
  <div class="cnt-bm-bg mid"></div>
</div>
 
<iframe name="openwindow" width="0" height="0" class="dn" src="./templates/blank.html">
</iframe>
<form id="downloadform" class="dn" target="openwindow" method="get" action="#">
<input id="detoken" name=etoken" value="">
<input id="dfileId" name="fileId" value="">
</form>
<div id="piclightBox" style="display:none;">
</div>
<div id="contentmenuwrap" class="dn abs bsc whitebg w-150 cmenu" style="display: none; "><ul></ul></div>

